package com.itnetwork.ServiceImp;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.itnetwork.DaoImp.CategoryDaoImp;
import com.itnetwork.DaoImp.NewsDaoImp;
import com.itnetwork.Entity.Category;
@Component("categoryServiceImp")
public class CategoryServiceImp {
	private NewsDaoImp newsDaoImp;
	private CategoryDaoImp categoryDaoImp;
	private List<Category> categorys=new ArrayList<Category>();
	@Transactional(readOnly=true)
	public Category getCategoryInfo(int id)
	{
		Category category=newsDaoImp.getCategoryById(id);//(Category)hibernateTemplate.get(Category.class, id);
		return category;
	}
	//获取category.cParent为null的栏目列表，即是二级栏目
	@Transactional(readOnly=true)
	public List<Category> getSCategoryList()
	{
		return categoryDaoImp.getSecondCategoryList();
		
	}
	//获取所有栏目列表
	@Transactional(readOnly=true)
	public List<Category> getCategoryList()
	{
		return categoryDaoImp.getCategoryList();
	}
	@Transactional(readOnly=true)
	public List<Object[]> getComboboxModel()//供后台栏目combobox用
	{
		System.out.println("categoryServiceImp start ...");
		return categoryDaoImp.getCategoryComboboxModel();
	}
	@Transactional
	public void saveCategory(Category category)
	{
		categoryDaoImp.saveCategory(category);
	}

	public NewsDaoImp getNewsDaoImp() {
		return newsDaoImp;
	}
	@Resource(name="newsDaoImp")
	public void setNewsDaoImp(NewsDaoImp newsDaoImp) {
		this.newsDaoImp = newsDaoImp;
	}
	public CategoryDaoImp getCategoryDaoImp() {
		return categoryDaoImp;
	}
	@Resource(name="categoryDaoImp")
	public void setCategoryDaoImp(CategoryDaoImp categoryDaoImp) {
		this.categoryDaoImp = categoryDaoImp;
	}

}
